﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cit.CDE.Net.Module.Commons;
using Module;
using Cit.CDE.Net.Module;
using cde.SystemCommon;
using UI.UserControl;
using Cit.CDE.Net.Service.ModuleFactory;
using System.Web.UI.HtmlControls;
using System.Text;

/// <summary>
/// Copyright (C)   jinggubang
/// FileName:        CourseListV.aspx.cs           
/// Author :         Wangbc
/// CDT:             2013-02-01           
/// Version:         1.0.0.0                
/// Depiction:       3我的课件查询/4共离课件查询   
/// </summary>
public partial class main_admin_CourseListV : UserControl.CommonPage
{
    /// <summary>
    /// EntityManager
    /// </summary>
    private CDEEntityManager em;
    private String EM;
    public string admin = "3";
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.strHc = "0";
        //设置母版页控件显示
        ((Literal)Master.FindControl("lblpath")).Text = MenuPath;

        EM = Request.QueryString[WEBConstants.EM_QUERY_STRING];

        string fold_name = Util.objectToString(Request.QueryString["FOL_ID__FOL_NAME"]);
        //初始化EM
        if (!Cit.CDE.Net.Module.Commons.CDEConstants.IsEmpty(EM))
        {
            em = cde.cache.CDEFactory.getEMByFullName(EM);
        }
        else
        {
            em = null;
        }

        Master.sc = this.CreatSc(em);
        //不显示钩选框
        Master.strHc = "1";

        List<CDECriteria> list_Criteria = new List<CDECriteria>();

        if (!EM.Equals("WEB.CSW_MANAGE_ADMIN"))
        {
            //只显示当前用户课件数据
            LoginOprator op = (LoginOprator)Session[Cit.CDE.Net.Module.Commons.CDEConstants.SESSION_LOIN_OPRATOR];
            Cit.CDE.Net.Module.CDECriteria dd = new CDECriteria("INSERT_USER", CDEConstCompare.Equality, op.SysID);            
            list_Criteria.Add(dd);            
        }
        else {
            //管理员
            admin = "4";
             //只显示共享数据
            LoginOprator op = (LoginOprator)Session[Cit.CDE.Net.Module.Commons.CDEConstants.SESSION_LOIN_OPRATOR];
            Cit.CDE.Net.Module.CDECriteria dd = new CDECriteria("STATE", CDEConstCompare.Equality, "0");
            Cit.CDE.Net.Module.CDECriteria d2 = new CDECriteria("AUDIT_STATE", CDEConstCompare.Equality, "1");
            list_Criteria.Add(dd);
            list_Criteria.Add(d2);
        }

        //文件夹课件显示
        if (fold_name != "")
        {
            Cit.CDE.Net.Module.CDECriteria fold = new CDECriteria("FOL_ID__FOL_NAME", CDEConstCompare.Equality, fold_name);
            list_Criteria.Add(fold);
            this.cmdback.Visible = true;
        }
        else {
            this.cmdback.Visible = false ;
        } 

        //传入Master画面
        Context.Items["list_Criteria"] = list_Criteria;

        //设置母版页控件事件
        ((SimpleResultDataGrid)Master.FindControl("dgmeisai")).ItemDataBound += new DataGridItemEventHandler(this.itemDataBound);
    }
    /// <summary>
    /// 操作事件处理
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void itemDataBound(object sender, DataGridItemEventArgs e)
    {
        //控制母版页控件显示内容
        ((SimpleResultDataGrid)Master.FindControl("dgmeisai")).Columns[((SimpleResultDataGrid)Master.FindControl("dgmeisai")).Columns.Count - 1].Visible = true;
    }
     

    /// <summary>
    /// 返回按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void cmdCancel_Click(object sender, EventArgs e)
    {
       

        if (Sel_MenuNode == null)
            return;
        
        StringBuilder url = new StringBuilder();
        url.Append("../course/FolderList.aspx?EM=WEB.FOL_MANAGE&sel_menu_id=b0102");       
        url.Append("&IsBackSc=1");
        Response.Redirect(url.ToString());

    } 
}
